package com.fit.entities.training;

import javax.persistence.AssociationOverride;
import javax.persistence.AssociationOverrides;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.Table;
import javax.persistence.Transient;

import com.fit.entities.coach.Coach;
import com.fit.entities.sport.Sport;




@Entity
@Table(name = "coach_sport_training")

@AssociationOverrides({
	@AssociationOverride(name = "pk.coach", joinColumns = @JoinColumn(name = "coach_jmbg")),
	@AssociationOverride(name = "pk.sport", joinColumns = @JoinColumn(name = "sport_id")) })

public class Training {
	

	@EmbeddedId
	private TrainingPK pk = new TrainingPK();
	
	@Column(name="komentar",nullable=true)
	private String komentar;

	public String getKomentar() {
		return komentar;
	}

	public void setKomentar(String komentar) {
		this.komentar = komentar;
	}

	public TrainingPK getPk() {
		return pk;
	}

	public void setPk(TrainingPK pk) {
		this.pk = pk;
	}
	
	public void setCoach(Coach coach){
		getPk().setCoach(coach);
	}
	
	@Transient
	public Coach getCoach(){
		return getPk().getCoach();
	}
	
	public void setSport(Sport sport){
		getPk().setSport(sport);
	}
	
	@Transient
	public Sport getSport(){
		return getPk().getSport();
	}
	
	
	public boolean equals(Object o) {
		if (this == o)
			return true;
		if (o == null || getClass() != o.getClass())
			return false;

		Training that = (Training) o;

		if (getPk() != null ? !getPk().equals(that.getPk())
				: that.getPk() != null)
			return false;

		return true;
	}
}
